package com.example.demo.dao;

import com.example.demo.model.Userinfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper1 {
    @Select("select * from userinfo")
    List<Userinfo> getAll();

    @Select("select * from userinfo where id=#{id}")
    Userinfo getById(@Param("id")Integer id);

    @Select("select * from userinfo where username=#{username} and password=#{password}")
    Userinfo login(@Param("username")String username,@Param("password")String password);

    @Update("update userinfo set password=#{password} where username=#{username}")
    int UpdateByName(Userinfo userinfo);

    @Update("update userinfo set username=#{username},password=#{password} where id=#{id}")
    int UpdateById(Userinfo userinfo);

    @Insert("insert into userinfo(id,username,password,photo,createtime,state) values(#{id},#{username},#{password},#{photo},#{createtime},#{state})")
    int Add(Userinfo userinfo);

    @Delete("delete from userinfo where id=#{id}")
    int DeleteById(@Param("id")Integer id);
}
